<template>
	<view class="page">
		<view class="title">
			<view>您好，一键注册！</view>
		</view>
		<view class="form">
			<view class="inputs">
				<view class="account">
					<input type="number" v-model="account" :adjust-position="false" placeholder="手机号" />
				</view>
				<view class="vcode">
					<input type="number" v-model="vcode" :adjust-position="false" placeholder="验证码" />
					<text v-if="vcodeTime==0" style="color:#ffde66" @click="getVcode">获取验证码</text>
					<text v-else style="color:#ccc">重新获取({{vcodeTime}}s)</text>
				</view>
			</view>
			<view class="button">
				<view @click="register">
					立即注册
				</view>
			</view>
			<view class="tip">
				<text @click="toLogin">已有帐号？去登录</text>
			</view>
		</view>
		<view class="pact">
			<checkbox :checked="pactChecked" activeBackgroundColor="#FFD640" activeBorderColor="#FFD640"
				borderColor="#000000" color="#fff" @click="pactChange" />
			<view>我已阅读并同意<text @click="toPact">《用户协议》</text>和<text @click="toPact">《隐私协议》</text></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account: "",
				vcode: "",
				pwdShow: false,
				pactChecked: false,
				vcodeTime: 0,
				vcodeTimer: null
			}
		},
		onLoad() {

		},
		methods: {
			register() {
				uni.showToast({
					title: "注册",
					icon: 'none'
				})
			},
			toLogin() {
				uni.redirectTo({
					url: "./login"
				})
			},
			getVcode() {
				this.vcodeTime = 60
				this.vcodeTimer = setInterval(() => {
					if (this.vcodeTime > 0) {
						this.vcodeTime--
					} else {
						clearInterval(this.vcodeTimer)
						this.vcodeTimer = null
					}
				}, 1000)
				uni.showToast({
					title: "获取验证码",
					icon: 'none'
				})
			},
			pactChange() {
				this.pactChecked = !this.pactChecked
			},
			toPact() {
				uni.showToast({
					title: "协议",
					icon: 'none'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		min-height: 100vh;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		.title {
			padding-top: 500rpx;
			padding-bottom: 120rpx;
			background: url("../../static/login-C/pageBg.png") no-repeat top center;
			background-size: 100%;

			view {
				padding-left: 64rpx;
				font-size: 44rpx;
				font-weight: 700;
				line-height: 1;
			}
		}

		.form {
			flex: 1;
			padding: 0 64rpx;

			.inputs {
				margin-bottom: 132rpx;

				view {
					height: 96rpx;
					border-radius: 48rpx;
					border: 1rpx solid rgba(204, 204, 204, 1);
					padding: 0 48rpx;
					display: flex;
					align-items: center;

					input {
						flex: 1;
					}
				}

				.account {
					margin-bottom: 48rpx;
				}

				.vcode {
					text {
						text-wrap: nowrap;
						font-size: 26rpx;
					}
				}
			}

			.button {
				view {
					line-height: 96rpx;
					border-radius: 48rpx;
					text-align: center;
					font-size: 32rpx;
					background: linear-gradient(90deg, rgba(255, 222, 102, 1) 0%, rgba(202, 245, 253, 1) 100%);
				}
			}

			.tip {
				font-size: 28rpx;
				text-align: center;
				margin-top: 30rpx;
			}
		}

		.pact {
			display: flex;
			align-items: center;
			justify-content: center;
			padding-bottom: 70rpx;
			font-size: 24rpx;

			text {
				color: #ffde66;
			}

			checkbox {
				:deep(.uni-checkbox-input) {
					border: 1rpx solid #000000;
				}

				transform:scale(0.6)
			}
		}
	}
</style>